﻿using System;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;
namespace AnyOffice.general.person_info
{
    public partial class group : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                DataTable table = new GroupDao().SelectAll(base.Conn, base.User.Identity.Name);
                if (table.Rows.Count > 0)
                {
                    this.rptGroup.DataSource = table;
                    this.rptGroup.DataBind();
                }
                else
                {
                    this.litMessage.Text = base.ShowMessage("无定义的用户组");
                }
            }
            if (this.Page.IsPostBack)
            {
                GroupDao dao2 = new GroupDao();
                GroupData data = new GroupData();
                data.UserId = base.User.Identity.Name;
                data.Name = this.txtGroupName.Text;
                data.GroupNo = this.txtGroupNo.Text;
                dao2.Insert(base.Conn, data);
                DataTable table2 = dao2.SelectAll(base.Conn, base.User.Identity.Name);
                this.rptGroup.DataSource = table2;
                this.rptGroup.DataBind();
                this.txtGroupName.Text = "";
                this.txtGroupNo.Text = "";
                this.litMessage.Text = "";
            }
        } 

    }
}
